//
//  ViewController.m
//  SZTZ
//
//  Created by 陈浩 on 2017/3/6.
//  Copyright © 2017年 陈浩. All rights reserved.
//

#import "ViewController.h"
#import "CHTabBarController.h"
#import "CHLoginViewController.h"
#import "CHSectionModel.h"
#import "CHUUIDManager.h"
@interface ViewController ()

@end

@implementation ViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    // Do any additional setup after loading the view, typically from a nib.
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:self.view.bounds];
    imageView.image = [UIImage imageNamed:@"start_bg"];
    [self.view addSubview:imageView];
    
   
    
}



//-(void)loadData{
//    
//    [[Globle getInstance].service RequestWithServiceName:@"fgwoa_getDwForAPP1" params:nil httpMethod:@"GET" resultIsDictionary:true completeBlock:^(id result) {
//     
//        if (result) {
//            NSMutableArray *tempArr = [NSMutableArray array];
//            for (NSMutableDictionary *dict in result) {
//            
//                CHSectionModel *model = [CHSectionModel objectWithKeyValues:dict];
//                
//                [tempArr addObject:model];
//            }
//            NSLog(@"获取下拉数据%@",tempArr);
//            //  是否跳过登录
//            [self isSkipLoginWithData:tempArr];
//        }
//    }];
//}
//


-(void)isSkipLogin{
    
    NSString *phonenumber = (NSString *)[Util getValue:@"phonenumber"];
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    params[@"shebeihao"] =[CHUUIDManager readUUID];
       
    [[Globle getInstance].service RequestWithServiceName:@"fgwoa_remitLogin" params:params httpMethod:@"POST" resultIsDictionary:true completeBlock:^(id result) {
        
        NSLog(@"%@是否跳过%@",[CHUUIDManager readUUID],result);
         UIWindow *window = [UIApplication sharedApplication].keyWindow;
        
        if (result) {
            
                window.rootViewController = [[CHTabBarController alloc] init];
            
            }else{
                
                CHLoginViewController *loginVC = [[CHLoginViewController alloc] init];
//                loginVC.datas = datas;
                window.rootViewController = loginVC;
            }
        
        [window makeKeyAndVisible];
        
    }];
}

-(NSString*) uuid {
    CFUUIDRef puuid = CFUUIDCreate( nil );
    CFStringRef uuidString = CFUUIDCreateString( nil, puuid );
    NSString * result = (NSString *)CFBridgingRelease(CFStringCreateCopy( NULL, uuidString));
    CFRelease(puuid);
    return result;
}


-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    
//    [self loadData];
//    //  是否跳过登录
    [self isSkipLogin];
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
